<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<link rel="shortcut icon" href="/asserts/images/favicon.ico" type="image/x-icon">
<head th:replace="common/main_layout::head">
</head>
<body class="main_body">
<div class="layui-layout layui-layout-admin">
    <!--导航栏-->
    <header th:replace="~{common/main_layout::header(active='edit')}"></header>
    <!--导航栏-->
    <div class="edit-body layui-container padding">
        <h2 class="edit-title" style="color: #009688;margin-left: 20px;
    margin-top: 5px;">完善个人信息</h2><hr/>
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
                <li class="layui-this">个人资料</li>
                <li>头像</li>
                <li>修改密码</li>
                <li>手机绑定</li>
                <li>实名认证</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <form method="post" class="layui-form" lay-filter="editinfo" th:action="@{/userInfo}">
                        <input type="text" hidden="hidden" name="userId" th:value="${session.user.userId}">
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户名</label>
                            <div class="layui-input-inline">
                                <input type="text" th:value="${session.user.userName}" name="username" placeholder="昵称" class="layui-input" lay-verify="required">
                            </div>
                        </div>
                        <div class="layui-form-item" id="area-picker">
                            <label class="layui-form-label">地址</label>
                            <div class="layui-inline">
                                <select name="province" id="province" class="province-selector">
                                    <option value="江西省">请选择省</option>
                                </select>
                            </div>
                            <div class="layui-inline">
                                <select name="city" id="city" class="city-selector">
                                    <option value="请选择市">请选择市</option>
                                </select>
                            </div>
                            <div class="layui-inline">
                                <select name="county" id="county" class="county-selector">
                                    <option value="请选择区/县">请选择区/县</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">详细地址</label>
                            <div class="layui-input-inline" style="width: 800px;">
                                <input type="text" id="detailAddress" name="detailAddress" class="layui-input" lay-verify="required">
                            </div>
                        </div>
                        <div class="layui-form-item" style="margin-left: 50px;">
                            <button class="layui-btn" lay-submit="">提交</button>
                            <button class="layui-btn layui-btn-primary" type="button" onclick="javascript:window.location.href='../'">返回首页</button>
                        </div>
                    </form>
                </div>
                <div class="layui-tab-item layui-form">
                    <div class="layui-form-item">
                        <div class="avatar-add" style="background-color: #eeeeee;">
                            <div class="upload-img">
                                <button type="button" class="layui-btn" id="upload-img">
                                    <i class="layui-icon">&#xe67c;</i>
                                    上传头像
                                </button>
                            </div>
                            <p>建议尺寸168*168,支持jpg、png、jpeg，最大不能超过2M</p>
                            <input type="file" class="layui-upload-file input_file" accept="image/jpg,image/jpeg,image/png" name="file">
                            <div id="prevModal">
                                <img class="layui-nav-img" id="img_prev">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-tab-item">
                    <form method="post" class="layui-form layui-form-pane" th:action="@{/userChangePassword}">
                        <div class="layui-form-item">
                            <label class="layui-form-label">原密码 <span style="color: #ff0000;">(*)</span></label>
                            <div class="layui-input-inline">
                                <input type="text" th:value="${session.user.getPassword()}" hidden="hidden" id="realpwd">
                                <input type="password" name="pwd" id="pwd" placeholder="请输入原密码" class="layui-input" lay-verify="required|pwdisright">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">新密码 <span style="color: #ff0000;">(*)</span></label>
                            <div class="layui-input-inline">
                                <input type="password" name="newpwd" id="newpwd" placeholder="请输入新密码" class="layui-input" autocomplete="off" lay-verify="required|newpwd">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">确认密码 <span style="color: #ff0000;">(*)</span></label>
                            <div class="layui-input-inline">
                                <input type="password" name="repwd" id="repwd" placeholder="再输入一次新密码" class="layui-input" lay-verify="required|repwd">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <button class="layui-btn" lay-submit="">确认修改</button>
                            <button class="layui-btn layui-btn-primary" type="button" onclick="javascript:window.location.href='../'">返回首页</button>
                        </div>
                    </form>
                </div>
                <div class="layui-tab-item">
                    <form class="layui-form" id="changePhone">
                        <div class="layui-form-item">
                            <label class="layui-form-label">新手机号码 <span style="color: #ff0000;">(*)</span></label>
                            <div class="layui-input-inline">
                                <input type="text" name="phonenumber" id="phonenumber" class="layui-input" lay-verify="phone|required|phoneExist" lay-filter="phone">
                            </div>
                            <button class="layui-btn" id="sendMes" type="button" onclick="sendMessage()">获取验证码 <span id="p_sendMes">(<span id="send_second">0</span>)</span></button>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">验证码 <span style="color: #ff0000;">(*)</span></label>
                            <div class="layui-input-inline">
                                <input type="text" name="identityCode" id="identityCode" class="layui-input" lay-verify="required|codeIsRight">
                            </div>
                        </div>
                        <div class="layui-form-item" style="margin-left: 50px;">
                            <button class="layui-btn" lay-submit="" id="phone-submit">提交</button>
                            <button class="layui-btn layui-btn-primary" type="button" onclick="javascript:window.location.href='../'">返回首页</button>
                        </div>
                    </form>
                </div>
                <div class="layui-tab-item">
                    实名认证暂未开放！
                </div>
            </div>
        </div>
    </div>
    <!--页尾-->
    <footer th:replace="common/main_layout::footer"></footer>
    <script th:src="@{/asserts/js/MainAndEditUser.js}"></script>
    <script type="text/javascript" src="/asserts/mods/layarea.js"></script>
</div>


<script type="text/javascript">

    let province;
    let county;
    let city;
    let detail;

    $(".input_file").change(function (e) {
        //console.log(e);
        var fileMsg = e.currentTarget.files;
        //console.log(fileMsg.length);
        if(fileMsg.length===0&&!ischange){
            $("#change").attr("disabled","disabled");
            return;
        }else {
            ischange = true;
        }
        if(ischange){
            $("#change").removeAttr("disabled");
        }
        if(fileMsg.length!==0){
            var objUrl = getObjectURL(this.files[0]);
            var size = this.files[0].size;
            if(size>=2*1024*1024){
                $(".alert-warning").css("display","block");
                return;
            }
            if(objUrl){
                $("#image").attr("src", objUrl);
                //console.log(this.files[0]);
                img_file = this.files[0];
            }
        }

    });


</script>
</body>
</html>